set more off

use dataset, clear

*** recoding for log scale ***

forvalues i = 1(1)1000 {
	local log`i' = log(`i'+1)
}

*** do the graph ***

drop if mi(lfinesandforfeitspcp) | mi(anyblackgov)

local t 5
xtile pctblackq1 = pctblack if anyblackgov == 1, nq(`t')
xtile pctblackq0 = pctblack if anyblackgov == 0, nq(`t')

gen pctblackq = pctblackq1
replace pctblackq = pctblackq0 if mi(pctblackq)

collapse lfinesandforfeitspcp pctblack (semean) se=lfinesandforfeitspcp, by(pctblackq anyblackgov)

drop if mi(anyblackgov)

gen ub = lfinesandforfeitspcp+1.96*se
gen lb = lfinesandforfeitspcp-1.96*se

gen mylab = ""
replace mylab = "Without black councilor" if anyblackgov == 0 & pctblackq == 2
replace mylab = "With black councilor" if anyblackgov == 1 & pctblackq == 2


#delimit;

gr tw
	(con lfinesand pctblackq if anyblackgov == 0, col(black))
	(con lfinesand pctblackq if anyblackgov == 1, col(black))
	(rspike ub lb pctblackq, col(black))
	(sc lfinesand pctblackq, msym(none) mlab(mylab) mlabpos(3))
	,
		legend(off)
		ylab(
			`log5' "5"
			`log10' "10"
			`log15' "15"
			,
			angle(horiz)
		)
		ytitle("Fines revenue per capita")
		xtitle("Quintile of black population")
		plotregion(style(none))
		
		;

#delimit cr

gr export "figureA6.eps", replace
shell epstopdf figureA6.eps
